<style type="text/css">
    .stafflist{
        width: 60px;text-align: center;float: left;
    }
    .stafflist img{
        width: 40px;
        height: 40px;
        margin: 10px;
        border-radius:50%;
    }
    .level{
        width: 100px;text-align: center;float: left;padding-top:18px;
        margin-left: 30px;
    }
    .level span:first-child{
        line-height: 2em
    }
</style>
<form id="add-form" class="form-horizontal col-sm-12" role="form" data-toggle="validator" method="POST" action="">
    {:token()}

    <div class="form-group">

        <div class="col-xs-12 col-sm-6">
            <div class="form-group col-sm-10">
                <label> <span style="color:red;">*</span>采购单编号:</label>
                <input class="form-control" data-rule="required" name="row[num]" type="text" value="{$num}">
            </div>
        </div>
        <div class="col-xs-12 col-sm-6">
            <div class="form-group col-sm-10">
                <label> <span style="color:red;">*</span>采购日期:</label>
                <input class="form-control datetimepicker" data-rule="required" name="row[date]" type="text" data-date-format="YYYY-MM-DD">
            </div>
        </div>
        <div class="col-xs-12 col-sm-6">
            <div class="form-group col-sm-10">
                <label><span style="color:red;">*</span>供应商: <a class="btn-dialog {:$auth->check('qingdongwms/stock/supplier/add')?'':'hide'}" data-url="qingdongwms/stock/supplier/add" data-title="新建供应商" data-refresh="true">新建</a></label>
                <select  name="row[supplier_id]" class="form-control selectpicker" data-live-search="true">
                    {foreach name="supplier" id="v"}
                    <option value="{$v.id}">{$v.name}</option>
                    {/foreach}

                </select>
            </div>
        </div>
        <div class="col-xs-12 col-sm-6">
            <div class="form-group col-sm-10">
                <label> <span style="color:red;">*</span>采购金额:</label>
                <input class="form-control" data-rule="required" name="row[money]" type="number">
            </div>
        </div>

        <div class="col-xs-12 col-sm-12">
            <div class="form-group col-sm-12">
                <label>备注:</label>
                <textarea  class="form-control" rows="5" name="row[remark]"
                placeholder="请输入备注"></textarea>
            </div>
        </div>
        <div class="col-xs-12 col-sm-12">
            <div class="form-group col-sm-10">
                <label>商品列表:</label>
            </div>
        </div>
        <div class="col-xs-12 col-sm-12">
            <div class="form-group col-sm-12">

                <table class="table table-responsive fieldlist" data-name="row[product]" data-template="testtpl" data-tag="tr">
                    <tr>
                        <td>产品</td>
                        <td>零售价</td>
                        <td>批发价</td>
                        <td>数量</td>
                        <td></td>
                    </tr>
                    <tr>
                        <td colspan="5"><a href="javascript:;" class="btn btn-sm btn-success btn-append"><i class="fa fa-plus"></i> 追加</a></td>
                    </tr>
                    <textarea name="row[product]" class="form-control hide" cols="30" rows="5"></textarea>
                </table>


            </div>
        </div>


    </div>


    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>


<!--定义模板-->
<script type="text/html" id="testtpl">
    <tr class="form-inline">
        <td>
            <input type="hidden" name="row[<%=name%>][<%=index%>][product_id]" value="<%=row['product_id']%>" >
            <div class="form-control" style="width: 90%">

                <a href="javascript:void(0)" class="select-product"
                   data-name="row[<%=name%>][<%=index%>][product_id]"
                   data-url="qingdongwms/product/product/index?isselect=1"  >
                    <% if(row['product_name']){%>
                    <%=row['product_name']%>
                    <% }else{%>
                    【请点击选择】
                    <% }%>
                </a>

            </div></td>
        <td style="width: 80px"><input type="number" name="row[<%=name%>][<%=index%>][price]" style="width: 80px"
                                       class="form-control price" value="<%=row['price']%>" placeholder="--"></td>
        <td style="width: 80px"><input type="number" name="row[<%=name%>][<%=index%>][wholesale]" style="width: 80px"
                                       class="form-control price2" value="<%=row['wholesale']%>" placeholder="--"></td>
        <td style="width: 80px"><input type="number" name="row[<%=name%>][<%=index%>][number]" style="width: 80px"
                                       class="form-control number" value="1" ></td>

        <td style="width: 120px"><span class="btn btn-sm btn-danger btn-remove"><i class="fa fa-times"></i></span> <span class="btn btn-sm btn-primary btn-dragsort"><i class="fa fa-arrows"></i></span></td>
    </tr>
</script>
